def quick_sort(arr):
    if len(arr) <= 1:
        return arr
    # 选择最后一个元素作为基准值
    pivot = arr[-1]
    # 划分三个子列表
    left = [x for x in arr[:-1] if x <= pivot]
    right = [x for x in arr[:-1] if x > pivot]
    # 递归排序并合并结果
    return quick_sort(left) + [pivot] + quick_sort(right)